//
//  ICReloadStyleView.m
//  ICome
//
//  Created by Administrator on 2017/8/8.
//  Copyright © 2017年 iCom. All rights reserved.
//

#import "ICReloadStyleView.h"
#import "ICHeaderFile.h"

@interface ICReloadStyleView()
@property (nonatomic, strong)UIImageView *imageView;
@property (nonatomic, strong)UILabel *emptyStyleLabel;
@end

@implementation ICReloadStyleView

- (instancetype)initWithTitle:(NSString *)title placeholderImage:(UIImage *)image imageURL:(NSString *)url {
    if (self = [super init]) {
        if (![ICTools stringEmpty:url]) {
            [self.imageView sd_setImageWithURL:[NSURL URLWithString:url]];
        } else {
            self.imageView.image = image;
        }
        UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
        [self addGestureRecognizer:tap];
        self.backgroundColor = [UIColor whiteColor];
        self.emptyStyleLabel.text = title;
        [self setUI];
    }
    return self;
}

-(void)setUI {
    [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(110);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.emptyStyleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).offset(65);
        make.centerX.equalTo(self.mas_centerX);
    }];
}

-(UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        [self addSubview:_imageView];
    }
    return _imageView;
}

- (UILabel *)emptyStyleLabel {
    if (!_emptyStyleLabel) {
        _emptyStyleLabel = [[UILabel alloc] init];
        _emptyStyleLabel.font = [UIFont systemFontOfSize:17];
        _emptyStyleLabel.backgroundColor = [UIColor clearColor];
        _emptyStyleLabel.textAlignment = NSTextAlignmentCenter;
        _emptyStyleLabel.textColor = ICRGB(0xC5C5C5);
        _emptyStyleLabel.text = @"网络不给力,点击重新加载";
        [self addSubview:_emptyStyleLabel];
    }
    return _emptyStyleLabel;
}


-(void)tap{
    if(self.clickedAction)
    {
        self.clickedAction(@"tap");
    }
}





@end
